<?php
class authloader {
	private function add($cfg) {
		//adds a provider to the class
		$this->providers[$cfg['label']] = $cfg;
	}
	
	private function remove($label) {
		//removes a provider from the class
	}
	
	function labels() {
		//returns an array of provider labels
		$labels = array();
		foreach ($this->providers as $provider) {
			if (isset($provider['label'])) {
				$labels[] = $provider['label'];
			}
		}
		return $labels;
	}
	
	function type($label) {
		if (isset($this->providers[$label]['type'])) {
			return $this->providers[$label]['type'];
		} else {
			return null;
		}
	}
	function provider_config($label) {
		if (isset($this->providers[$label])) {
			return $this->providers[$label];
		} else {
			return null;
		}
	}
	function provider_count() {
	
	}
	
	function load_providers($file) {
		/* loads a list of provider configuration files from the site/config/auth folder
			 and passes the resulting provider configuration arrays to load_provider_config() */
			 if (file_exists($file)) {
			 		require_once($file);
			 		if (isset($providers)) {
			 			foreach ($providers as $provider) {
			 				$this->load_provider_file($provider);
			 			}
			 		}
			 }
	}
	private function load_provider_file($file) {
		/* loads an authentication provider from a given provider file from the site/config/auth folder */
		if (file_exists($file)) {
			require_once($file);
			if (isset($C)) {
					$this->add($C);
			}
		}
	}
	
	private $providers = array();
}
?>
